perm filename W.TEX[TEX,DEK] blob sn#841386 filedate 1987-06-13 generic text, type T, neo UTF8
\input webmac

\M1. In \sec38, define \\{str\_number} to be the same as \\{pool\_pointer},
and define $\\{str\_end}=128$.
In \sec39, delete the declaration of \\{str\_start}.
In \sec40, declare

\Y\P\4\&{function}\1\  \37$\\{length}(\|s:\\{str\_number})$: \37\\{integer};\6
\4\&{var} \37\|t: \37\\{pool\_pointer};\2\6
\&{begin} \37$\|t\K\|s$;\6
\&{while} $\\{str\_pool}[\|t]\I\\{str\_end}$ \1\&{do}\5
$\\{incr}(\|t)$;\2\6
$\\{length}\K\|t-\|s$;\6
\&{end};\par
\fi

\M2. In \sec41, define $\\{cur\_length}\S(\\{pool\_ptr}-\\{str\_ptr})$. In %
\sec43, declare

\Y\P\4\&{function}\1\  \37\\{make\_string}: \37\\{str\_number};\C{current
string enters the pool}\6
\4\&{var} \37\|t: \37\\{str\_number};\C{the result}\2\6
\&{begin} \37$\\{str\_room}(1)$;\5
$\\{append}(\\{str\_end})$;\6
$\|t\K\\{str\_ptr}$;\5
$\\{str\_ptr}\K\\{pool\_ptr}$;\5
$\\{make\_string}\K\|t$;\6
\&{end};\par
\fi

\M3. In \sec44, we can

\Y\P\D \37$\\{flush\_string}\S$\ \&{begin} \37\1\&{repeat} \37$\\{decr}(\\{str%
\_ptr})$;\6
\4\&{until}\5
$\\{str\_pool}[\\{str\_ptr}-1]=\\{str\_end}$;\2\6
$\\{pool\_ptr}\K\\{str\_ptr}$;\6
\&{end}\par
\fi

\M4. The comparison function in \sec45 is used only in \sec259, where we can
replace `  \&{if} $\\{length}(\\{text}(\|p))=\|l$ \&{then}   \&{if} $\\{str\_eq%
\_buf}(\\{text}(\|p),\|j)$' by
`  \&{if} $\\{str\_eq\_buf}(\\{text}(\|p),\|j,\|l)$'. The function now has
three parameters:

\Y\P\4\&{function}\1\  \37$\\{str\_eq\_buf}(\|s:\\{str\_number};\,\35\|k,\39%
\|l:\\{integer})$: \37\\{boolean};\C{test equality of strings}\6
\4\&{label} \37\\{exit};\6
\4\&{var} \37\|j: \37\\{pool\_pointer};\C{running index}\2\6
\&{begin} \37$\|j\K\|s$;\5
$\|s\K\|s+\|l$;\6
\&{if} $\\{str\_pool}[\|s]\I\\{str\_end}$ \1\&{then}\5
$\\{str\_eq\_buf}\K\\{false}$\6
\4\&{else} \&{begin} \37\&{while} $\|j<\|s$ \1\&{do}\6
\&{begin} \37\&{if} $\\{str\_pool}[\|j]\I\\{buffer}[\|k]$ \1\&{then}\6
\&{begin} \37$\\{str\_eq\_buf}\K\\{false}$;\5
\\{return};\6
\&{end};\2\6
$\\{incr}(\|j)$;\5
$\\{incr}(\|k)$;\6
\&{end};\2\6
$\\{str\_eq\_buf}\K\\{true}$;\6
\&{end};\2\6
\4\\{exit}: \37\&{end};\par
\fi

\M5. The procedure of \sec46 is modified in an obvious way.

The first three statements of \sec47 become just two:
`$\\{pool\_ptr}\K128$; $\\{str\_ptr}\K128$'. The body of the {\bf for} loop in %
\sec48
becomes just

\Y\P\&{if} $(\X0:Character \|k cannot be printed\X)$ \1\&{then}\6
\&{if} $\|k<\O{100}$ \1\&{then}\5
$\\{str\_pool}[\|k]\K\|k+\O{100}$\6
\4\&{else} $\\{str\_pool}[\|k]\K\|k-\O{100}$\2\6
\4\&{else} $\\{str\_pool}[\|k]\K\|k$\2\par
\fi

\M6. In \sec59, variable $j$ is no longer needed. If $0\L\|s<128$ and if $s$
isn't the current new-line character, we now say

\Y\P\&{begin} \37\&{if} $\\{str\_pool}[\|s]\I\|s$ \1\&{then}\6
\&{begin} \37$\\{print\_char}(\.{"\↑"})$;\5
$\\{prnt\_char}(\.{"\↑"})$;\6
\&{end};\2\6
$\\{print\_char}(\\{str\_pool}[\|s])$;\6
\&{end}\par
\fi

\M7. In the other case, where $\|s\G128$, we say

\Y\P\&{while} $\\{str\_pool}[\|s]\I\\{str\_end}$ \1\&{do}\6
\&{begin} \37$\\{print\_char}(\\{str\_pool}[\|s])$;\5
$\\{incr}(\|s)$;\6
\&{end}\2\par
\fi

\M8. In \sec407, similarly, variable $k$ is eliminated; the loop on~$k$
becomes a loop on~$s$,  \&{while} $\\{str\_pool}[\|s]\I\\{str\_end}$.

In \sec464, replace the two occurrences of `$\\{str\_start}[\\{str\_ptr}]$' by
`\\{str\_ptr}'.

The first loop in \sec603 becomes

\Y\P$\|k\K\\{font\_area}[\|f]$;\6
\&{while} $\\{str\_pool}[\|k]\I\\{str\_end}$ \1\&{do}\6
\&{begin} \37$\\{dvi\_out}(\\{str\_pool}[\|k])$;\5
$\\{incr}(\|k)$;\6
\&{end}\2\par
\fi


\inx
\:\\{append}, 2.
\:\\{boolean}, 4.
\:\\{buffer}, 4.
\:\\{cur\_length}, 2.
\:\\{decr}, 3.
\:\\{dvi\_out}, 8.
\:\\{exit}, 4.
\:\\{false}, 4.
\:\\{flush\_string}, \[3].
\:\\{font\_area}, 8.
\:\\{incr}, 1, 4, 7, 8.
\:\\{integer}, 1, 4.
\:\|{j}, \[4].
\:\\{length}, \[1], 4.
\:\\{make\_string}, \[2].
\:\\{pool\_pointer}, 1, 4.
\:\\{pool\_ptr}, 2, 3, 5.
\:\\{print\_char}, 6, 7.
\:\\{prnt\_char}, 6.
\:\\{return}, 4.
\:\\{str\_end}, 1, 2, 3, 4, 7, 8.
\:\\{str\_eq\_buf}, \[4].
\:\\{str\_number}, 1, 2, 4.
\:\\{str\_pool}, 1, 3, 4, 5, 6, 7, 8.
\:\\{str\_ptr}, 2, 3, 5, 8.
\:\\{str\_room}, 2.
\:\\{str\_start}, 1, 8.
\:\|{t}, \[1], \[2].
\:\\{text}, 4.
\:\\{true}, 4.
\fin
\:\X0:Character \|k cannot be printed\X
\U section~5.
\con